using logging;

interface Human{
    void show();
    void speech();
}

class Black: Human{
    public virtual void show(){ Log.print("黑皮肤"); }
    public virtual void speech(){ Log.print("说土著语"); }
}

class White: Human{
    public virtual void show(){ Log.print("白皮肤"); }
    public virtual void speech(){ Log.print("说英语"); }
}

class BlackFemale: Black{
    public override void show(){ Log.print("黑皮肤 女人"); }
    public override void speech(){ Log.print("说土著语 女人"); }
}

class BlackMale: Black{
    public override void show(){ Log.print("黑皮肤 男人"); }
    public override void speech(){ Log.print("说土著语 男人"); }
}

class WhiteFemale: White{
    public override void show(){ Log.print("白皮肤 女人"); }
    public override void speech(){ Log.print("说英语 女人"); }
}

class WhiteMale: White{
    public override void show(){ Log.print("白皮肤 男人"); }
    public override void speech(){ Log.print("说英语 男人"); }
}

abstract class HumanFactory{  // 简单工厂
    public void create_people(string type){  // 封装判断逻辑
        Human man;
        if(type == "black")
            man = create_black_people();
        else
            man = create_white_people();
        man.show();
        man.speech();
    }
    public abstract Human create_black_people();  // 封装对象的创建流程
    public abstract Human create_white_people();
}

// 注意区分，产品族是“男性”和“女性”，而不是黑人/白人。
class FemaleFactory: HumanFactory{  // 实际上产品族只是一层继承关系
    public override Human create_black_people(){
        return new BlackFemale();
    }
    public override Human create_white_people(){
        return new WhiteFemale();
    }
}

class MaleFactory: HumanFactory{
    public override Human create_black_people(){
        return new BlackMale();
    }
    public override Human create_white_people(){
        return new WhiteMale();
    }
}

class Demo{
    static void Main(){
        var type_runtime = "black";

        HumanFactory group = new MaleFactory();  // 客户端选择实例化一个产品族
        group.create_people(type_runtime);  // 产品族对象根据运行时参数，动态的实例化对象
    }
}
